import { Injectable } from '@angular/core';
import { BaseService } from './base.service';
import { ZeprideWorkflowNode } from '../models';

@Injectable({
  providedIn: 'root'
})
export class WorkflowNodeService extends BaseService {

  getFlowNodes(): Promise<ZeprideWorkflowNode[]> {
    const url = 'api/flowNode';
    return this.get(url);
  }

  getFlowNodeById(id: string): Promise<ZeprideWorkflowNode> {
    const url = `api/flowNode/${id}`;
    return this.get(url);
  }

  saveFlowNode(flowNode: ZeprideWorkflowNode): Promise<ZeprideWorkflowNode> {
    const url = 'api/flowNode';
    return this.post(url, flowNode);
  }

  deleteFlowNode(nodeId: string) {
    const url = `api/flowNode/${nodeId}`;
    return this.delete(url);
  }

}
